Kanzi 3.9.10
kanzi::NodeEffect2D Class Referenceabstract

Use node effects to apply post-processing effects to 2D nodes. More...

#include <kanzi/core.ui/node/node_effect2d.hpp>

Inheritance diagram for kanzi::NodeEffect2D:
[legend]

Public Member Functions

void attach (Node *node)
 Attaches the node effect.
 
BindingLookupContextPtr createLookupContext (NodeEffect2DSharedPtr templateRoot)
 Creates a lookup context for a given effect.
 
NodeEffectRenderer2DUniquePtr createRenderer ()
 Creates a renderer instance.
 
void detach ()
 Detaches the node effect.
 
unsigned int getEffectPaddingChangeCounter () const
 Gets the effect quad padding change counter.
 
Vector4 getEffectQuadPadding () const
 Gets the effect quad padding.
 
Vector2 getEffectQuadPaddingOffset () const
 Gets the effect quad offset relative relative to the top-left corner of the node.
 
Vector2 getEffectQuadPaddingSize () const
 Gets the effect quad padding size.
 
bool getEnabled () const
 Gets the value of EnabledProperty.
 
NodegetHostNode () const
 Gets the node that hosts the effect.
 
NodeEffect2DgetParent () const
 Gets the parent of a node effect.
 
NodeEffectRenderer2DgetRendererInstance () const
 Gets a pointer to NodeEffectRenderer2D instance or null pointer if none exists.
 
NodeEffect2DSharedPtr getTemplateRoot () const
 Gets the template root of this node effect.
 
bool isAlphaRequired () const
 Indicates whether the effect requires alpha channel for the result.
 
bool isAttached () const
 Returns whether a node effect is attached to a node.
 
bool isAttaching () const
 Returns whether a node effect is attaching to a node.
 
bool isDetached () const
 Returns whether a node effect is detached from a node.
 
bool isDetaching () const
 Returns whether a node effect is detaching from a node.
 
bool isRenderingRequired ()
 Indicates whether the effect requires rendering.
 
ObjectSharedPtr lookupObject (string_view relativePath)
 Lookup for an object from the effect.
 
template<typename T >
shared_ptr< TlookupObject (string_view relativePath)
 Lookup a relative object of a given type.
 
void setEffectPaddingChangeCounter (unsigned int value)
 Sets the effect quad padding change counter.
 
void setEnabled (bool value)
 Sets the value of EnabledProperty.
 
void setParent (NodeEffect2D *parent)
 Sets the parent of a node effect.
 
void setTemplateRoot (NodeEffect2DSharedPtr templateRoot)
 Sets the template root for this node effect.
 
void unregisterEffectRenderer (NodeEffectRenderer2D *effectRenderer)
 Unregister effect renderer.
 
 ~NodeEffect2D ()
 
- Public Member Functions inherited from kanzi::Resource
virtual unsigned int getCPUMemoryUsage () const
 Function for getting the memory usage of a resource.
 
const string & getName () const
 Gets the resource name.
 
const string & getUrl () const
 Gets the resource URL.
 
bool isKeepAlive () const
 Tells if the resource has keep alive flag set.
 
void reload ()
 
void reloadFromFile (string_view filePath)
 
void reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser)
 
void setKeepAlive (bool keepAlive)
 Sets the keep alive flag.
 
void setUrl (string_view url)
 Sets the resource URL.
 
 ~Resource () override
 Destructor.
 
- Public Member Functions inherited from kanzi::Object
AppliedStyleEntrySharedPtr applyObjectStyle (kanzi::StyleSharedPtr style)
 Applies a style to an object.
 
void applyObjectStyles ()
 Apply all styles for an object node.
 
DomaingetDomain () const
 Returns the domain the object belongs to.
 
const MetaclassgetDynamicMetaclass () const override
 Returns the metaclass of the dynamic type of the object.
 
MainLoopSchedulergetMainLoopScheduler () const
 Returns the MainLoopScheduler instance of the associated Domain.
 
detail::MessageDispatcher * getMessageDispatcher () const
 Returns the message dispatcher of the object.
 
ResourceManagergetResourceManager () const
 Returns the resource manager of the object.
 
ScriptingContextSharedPtr getScriptingContext () const
 Gets the scripting context of the object.
 
 Object (Domain *domain)
 
void setScriptingContext (ScriptingContextSharedPtr context)
 Sets the scripting context of the object.
 
void unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry)
 
void unapplyObjectStyles ()
 Unapplies and removes all applied styles.
 
 ~Object () override
 
- Public Member Functions inherited from kanzi::MetaObject
bool isTypeOf (const Metaclass *objectType) const
 Determines if the type of this object is the given type or derived from it.
 
virtual ~MetaObject ()
 
- Public Member Functions inherited from kanzi::PropertyObject
template<typename DataType >
void addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void addPropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 Adds a property modifier without notifying handlers.
 
template<typename DataType >
void addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 
PropertyStorageContainer::iterator beginPropertyStorage ()
 Returns the begin iterator to the internal property storage container.
 
PropertyStorageContainer::const_iterator beginPropertyStorage () const
 Returns the begin iterator to the internal property storage container.
 
void clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
void copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType)
 Copies local value of single property from another object.
 
void copyLocalValues (const PropertyObject &other)
 Copies all local values from another object.
 
PropertyStorageContainer::iterator endPropertyStorage ()
 Returns the end iterator to the internal property storage container.
 
PropertyStorageContainer::const_iterator endPropertyStorage () const
 Returns the end iterator to the internal property storage container.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalProperty (const PropertyType< DataType > &propertyType) const
 Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value.
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property type.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers.
 
template<typename DataType >
size_t getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const
 Gets number of current notification handlers for given property type.
 
bool hasBaseValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value, disregarding modifiers.
 
bool hasLocalValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a local value set for the property.
 
bool hasNonClassValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a value of any precedence higher than class default value set for the property.
 
bool hasValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value.
 
bool isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const
 
 PropertyObject ()
 
void removeKzbProperties ()
 Remove all KZB properties.
 
void removeKzbProperties (flat_set< AbstractPropertyType > *keepProperties)
 Remove all KZB properties that are not included in a given set.
 
template<typename DataType >
void removeLocalPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer)
 
void removeLocalValue (AbstractPropertyType propertyType)
 Removes the local value associated with the property.
 
template<typename DataType >
void removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer)
 
template<typename DataType >
void setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 
template<typename DataType >
void setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 Sets the local value of a property type.
 
void setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
KZ_DEPRECATED void validatePropertyModifiers (AbstractPropertyType propertyType)
 Validates property modifiers and notifies handlers.
 
void validatePropertyModifiersAndNotifyHandlers (AbstractPropertyType propertyType)
 Validates property modifiers and notifies handlers.
 
virtual ~PropertyObject ()
 
- Public Member Functions inherited from kanzi::BindingHostConceptImpl< NodeEffect2D >
void addBindingRuntime (AbstractBindingRuntimeSharedPtr entry, shared_ptr< void > owner)
 Adds an already-created binding runtime to this binding host.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding)
 Wrapper for setting a binding with no target.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyValuePrecedence precedence)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot)
 Sets a binding with no target.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyValuePrecedence precedence)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner)
 Wrapper for setting a binding with no target.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType)
 Wrapper for setting a binding with owner.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding with owner.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< NodeEffect2D > templateRoot)
 Sets a binding with no target.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Sets a binding to a certain property.
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Sets a modifier binding.
 
- Public Member Functions inherited from kanzi::BindingHostConcept
BindingRuntimeConstIterator beginBindingRuntimes () const
 Returns an iterator to the beginning of binding runtimes.
 
BindingRuntimeConstIterator endBindingRuntimes () const
 Returns an iterator to the end of binding runtimes.
 
AbstractBindingRuntimeSharedPtr getBindingRuntime (size_t idx)
 Gets binding by index.
 
size_t getBindingRuntimeCount () const
 Gets the number of binding runtimes added to this node.
 
void removeAllBindings ()
 Removes all binding runtimes.
 
void removeBinding (BindingRuntimeHandle &bindingRuntime)
 Removes a binding runtime added earlier.
 
void removeBindingsWithOwner (shared_ptr< void > owner)
 Removes all binding runtimes with the specified owner.
 

Static Public Attributes

static PropertyType< boolEnabledProperty
 Sets whether the effect is enabled.
 

Protected Member Functions

virtual NodeEffectRenderer2DUniquePtr createRendererOverride ()=0
 Creates a renderer instance.
 
virtual void initializeRendererOverride ()=0
 Initializes a previously created renderer instance.
 
virtual bool isRenderingRequiredOverride ()
 Implementation-dependent check on whether effect rendering is required.
 
virtual ObjectSharedPtr lookupObjectOverride (string_view initialPart, string_view remainingPart)
 Lookup for an object from the effect.
 
 NodeEffect2D (Domain *domain, string_view name)
 Constructor.
 
virtual void onAttached ()
 Called by Kanzi when effect is attached.
 
virtual void onDetached ()
 Called by Kanzi when effect is detached.
 
void onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) override
 PropertyObject::onPropertyChanged implementation.
 
void setAlphaRequired (bool required)
 Sets the framebuffer alpha channel requirements of the effect.
 
void setEffectQuadPadding (float left, float right, float top, float bottom)
 Sets the padding required by the effect around the node bounds during the rendering of the effect.
 
- Protected Member Functions inherited from kanzi::Resource
virtual unsigned int getCPUMemoryUsageOverride () const
 
virtual void reloadFromFileOverride (string_view filePath)
 
virtual void reloadFromKzbOverride (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser)
 
virtual void reloadOverride ()
 
 Resource (Domain *domain, string_view name)
 Constructor.
 
- Protected Member Functions inherited from kanzi::Object
void initialize ()
 
void onCopy (const Object &other)
 
- Protected Member Functions inherited from kanzi::MetaObject
void initialize ()
 
 MetaObject ()
 
- Protected Member Functions inherited from kanzi::PropertyObject
AbstractPropertyTypeDescriptor::ValueSourceEntryacquireLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Acquires a local value source entry that is free for the assignment of a value.
 
AbstractPropertyTypeDescriptor::ModifierStorageacquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::NotificationStorageacquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
PropertyStoragePtr acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
template<typename DataType >
void addPropertyModifierBase (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner, bool notify)
 Adds a property modifier entry to the property modifier stack and validates them.
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 Internally adds a property value source.
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 Internally adds a property value source.
 
AbstractPropertyTypeDescriptor::ValueSourceEntryconstructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
PropertyStoragePtr constructPropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
void copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &otherPropertyStorage)
 Copy local value from property storage.
 
AbstractPropertyTypeDescriptor::ModifierStoragefindModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStoragefindNotificationStorage (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::PropertyStoragefindPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the property storage for given property type descriptor.
 
PropertyStoragePtr findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const
 Gets property storage intrusive pointer which you can use to hold a reference until the end of the operation.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByNameAndDataType (string_view name, PropertyDataType dataType) const
 Finds a property type descriptor by name and data type.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByQualifiedNameAndDataType (string_view qualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with qualified names.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with unqualified names.
 
AbstractPropertyTypeDescriptor::ValueSourcegetClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetNonClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetTopValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the top-level value source for a given property descriptor.
 
virtual void notifyPropertyHandlers (PropertyStoragePtr &storagePtr, PropertyNotificationReason reason)
 Notifies all property handlers on a property storage.
 
void onCopy (const PropertyObject &other)
 
void removeLocalValue (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Removes a local value from the given property storage.
 
void removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner)
 Removes a property value source.
 
void validatePropertyModifiers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers without notifying handlers.
 
void validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers and notifies handlers.
 
- Protected Member Functions inherited from kanzi::BindingHostConceptImpl< NodeEffect2D >
NodeEffect2DgetThisObject ()
 Internal accessor for the Curiously Recurring Template Pattern.
 
const NodeEffect2DgetThisObject () const
 Internal accessor for the Curiously Recurring Template Pattern.
 
- Protected Member Functions inherited from kanzi::BindingHostConcept
void attachBindings ()
 Attach all bindings stored in this object.
 
void detachBindings ()
 Detach bindings.
 

Additional Inherited Members

- Public Types inherited from kanzi::PropertyObject
typedef PropertyStorageContainer::const_iterator PropertyStorageConstIterator
 
typedef vector< PropertyStoragePtrPropertyStorageContainer
 
typedef PropertyStorageContainer::iterator PropertyStorageIterator
 
typedef intrusive_ptr< AbstractPropertyTypeDescriptor::PropertyStoragePropertyStoragePtr
 
typedef PropertyStorageContainer::reverse_iterator PropertyStorageReverseIterator
 
- Public Types inherited from kanzi::BindingHostConcept
using BindingHostConceptSharedPtr
 Binding host concept shared pointer type.
 
using BindingRuntimeConstIterator
 Const iterator for binding runtimes.
 
using BindingRuntimeContainer
 Container for binding runtimes.
 
using BindingRuntimeIterator
 Iterator for binding runtimes.
 
- Static Public Member Functions inherited from kanzi::Object
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class.
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info.
 
- Static Public Member Functions inherited from kanzi::MetaObject
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class.
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info.
 
- Protected Types inherited from kanzi::Object
typedef vector< AppliedStyleEntrySharedPtrAppliedStyleContainer
 Applied style container.
 
- Protected Attributes inherited from kanzi::Object
AppliedStyleContainer m_appliedStyles
 Listing of applied styles applied to this object.
 
- Protected Attributes inherited from kanzi::BindingHostConcept
BindingRuntimeContainer m_bindingRuntimes
 Bindings in this object.
 

Detailed Description

Use node effects to apply post-processing effects to 2D nodes.

Examples

To create an effect:

// An effect that is assigned to a 2D node is an effect prefab.
// Before you can construct an effect prefab, you must create an effect template.
// This example creates an effect template for the ShadowEffect2D effect prefab.
NodeEffectTemplate2DSharedPtr shadowEffectTemplate =
NodeEffectTemplate2D::create(ShadowEffect2D::getStaticMetaclass()->getName(), "DropShadow");
// Create a node effect prefab from the effect template.
NodeEffectPrefab2DSharedPtr shadowEffectPrefab =
NodeEffectPrefab2D::create(getDomain(), "DropShadow prefab", shadowEffectTemplate);

To assign an effect to a 2D node:

// To assign an effect prefab to a 2D node, set the Node2D::EffectPrefabProperty.
node2d->setProperty(Node2D::EffectPrefabProperty, shadowEffectPrefab);
// To assign an effect prefab to a 2D node, call the Node2D::setEffectPrefab method.
node2d->setEffectPrefab(shadowEffectPrefab);

To set the effect properties:

// Create an effect template.
NodeEffectTemplate2DSharedPtr shadowEffectTemplate =
NodeEffectTemplate2D::create(ShadowEffect2D::getStaticMetaclass()->getName(), "DropShadow");
// Set the value of the AngleProperty in the template. This value serves as the default value
// of the property in instances of the effect prefab.
shadowEffectTemplate->addPropertyValue(ShadowEffect2D::AngleProperty, Variant(35.f));
// Create an effect prefab.
NodeEffectPrefab2DSharedPtr shadowEffectPrefab =
NodeEffectPrefab2D::create(getDomain(), "DropShadow prefab", shadowEffectTemplate);
// Assign the effect to a 2D node.
node2d->setEffectPrefab(shadowEffectPrefab);
// Get the node-specific effect instance created from the assigned prefab.
ShadowEffect2DSharedPtr shadowEffect = dynamic_pointer_cast<ShadowEffect2D>(node2d->getEffect());
// Set the shadow distance to 15 pixels for this node only. This overrides
// the property default value defined by the ShadowEffect2D metaclass.
shadowEffect->setDistance(15.f);
// Set the direction of the shadow to 55 degrees relative to the positive x axis.
// This overrides the default value of 35 degrees set in the shadow effect template.
shadowEffect->setAngle(55.f);

To set multiple nodes to use the same effect:

// Create an effect template.
NodeEffectTemplate2DSharedPtr shadowEffectTemplate =
NodeEffectTemplate2D::create(ShadowEffect2D::getStaticMetaclass()->getName(), "DropShadow");
// Create an effect prefab from the effect template.
NodeEffectPrefab2DSharedPtr shadowEffectPrefab =
NodeEffectPrefab2D::create(getDomain(), "DropShadow prefab", shadowEffectTemplate);
// Set two nodes to use the same effect prefab. The nodes create separate instances
// of NodeEffect2D but share the same NodeEffectPrefab2D instance.
node1->setEffectPrefab(shadowEffectPrefab);
node2->setEffectPrefab(shadowEffectPrefab);

To enable and disable an effect:

// Enable an effect on a 2D node by assigning an effect prefab.
node2d->setEffectPrefab(shadowEffectPrefab);
// Disable an effect by assigning a nullptr or an empty shared pointer.
node2d->setEffectPrefab(nullptr);

To create an effect type:

// To create an effect resource type, inherit a new class from NodeEffect2D
// and define a new associated metaclass. Each effect resource class must
// have an associated renderer class inherited from NodeEffectRenderer2D.
class EmptyEffectRenderer2D;
using EmptyEffectRenderer2DUniquePtr = unique_ptr<EmptyEffectRenderer2D>;
class EmptyEffect2D;
using EmptyEffect2DSharedPtr = shared_ptr<EmptyEffect2D>;
// EmptyEffect2D defines a new effect that defines no properties
// nor padding.
class EmptyEffect2D : public NodeEffect2D
{
public:
KZ_METACLASS_BEGIN(EmptyEffect2D, NodeEffect2D, "Kanzi.EmptyEffect2D")
// Create an instance of EmptyEffect2D.
static EmptyEffect2DSharedPtr create(Domain* domain, string_view name)
{
return make_polymorphic_shared_ptr<Resource>(new EmptyEffect2D(domain, name));
}
protected:
// Constructor.
explicit EmptyEffect2D(Domain* domain, string_view name) :
NodeEffect2D(domain, name)
{
}
// NodeEffect2D::createRendererOverride implementation.
NodeEffectRenderer2DUniquePtr createRendererOverride() override;
// NodeEffect2D::initializeRendererOverride implementation.
void initializeRendererOverride() override
{
}
};
// EmptyEffectRenderer2D implements the rendering of the effect.
// Because this example effect does not render anything, Kanzi renders
// the original node as is.
class EmptyEffectRenderer2D : public NodeEffectRenderer2D
{
public:
// Creates an instance of MinimalEffectRenderer2D. Never call this
// function directly. Instead, use NodeEffect2D::createRenderer().
static EmptyEffectRenderer2DUniquePtr create(EmptyEffect2DSharedPtr effect)
{
return unique_ptr<EmptyEffectRenderer2D>(new EmptyEffectRenderer2D(effect));
}
private:
// Constructor.
explicit EmptyEffectRenderer2D(EmptyEffect2DSharedPtr effect) :
{
}
// Implementation of NodeEffectRenderer2D::beginEffectOverride.
void beginEffectOverride(Renderer3D& /*renderer*/, CompositionStack& /*compositionStack*/, CompositionManager* /*compositionManager*/,
const Matrix3x3& /*worldTransform*/, const CompositionContentRequirements& /*requirements*/) override
{
}
// Implementation of NodeEffectRenderer2D::endEffectOverride.
void endEffectOverride(Renderer3D& /*renderer*/, CompositionStack& /*compositionStack*/, CompositionManager* /*compositionManager*/) override
{
}
// Implementation of NodeEffectRenderer2D::blitEffectOverride.
void blitEffectOverride(Renderer3D& /*renderer*/, CompositionStack& /*compositionStack*/, CompositionManager* /*compositionManager*/,
const QuadDescription& /*effectQuad*/, const Matrix3x3& /*transform*/, const Matrix4x4* /*perspectiveMatrix*/,
const Matrix4x4* /*projectionMatrix*/, int /*blendMode*/, bool /*needsClear*/) override
{
}
// Implementation of NodeEffectRenderer2D::restoreResourcesOverride.
virtual void restoreResourcesOverride() override
{
}
};
NodeEffectRenderer2DUniquePtr EmptyEffect2D::createRendererOverride()
{
return EmptyEffectRenderer2D::create(static_pointer_cast<EmptyEffect2D>(shared_from_this()));
}

To use bindings with effects:

// Create an outline effect template.
NodeEffectTemplate2DSharedPtr outlineEffectTemplate =
NodeEffectTemplate2D::create(OutlineEffect2D::getStaticMetaclass()->getName(), "OutlineEffect");
// Create a shadow effect template.
NodeEffectTemplate2DSharedPtr shadowEffectTemplate =
NodeEffectTemplate2D::create(ShadowEffect2D::getStaticMetaclass()->getName(), "DropShadow");
// Add to the shadow effect a binding that binds the shadow distance to a value in the root
// of the effect template.
shadowEffectTemplate->addBinding(BindingLoadInfo(Binding::create("##Template", ShadowEffect2D::DistanceProperty), ShadowEffect2D::DistanceProperty));
// Add to the host node a binding that binds the shadow distance value in the effect template root
// to the value in the node.
node->setBinding(
ToSourceBinding::create(
ObjectPropertyBindingSource::create(".", ShadowEffect2D::DistanceProperty),
ObjectPropertyBindingSource::create(".Node2D.Effect", ShadowEffect2D::DistanceProperty)));
// Create an effect stack template
NodeEffectTemplate2DSharedPtr effectStackTemplate = NodeEffectTemplate2D::create(EffectStack2D::getStaticMetaclass()->getName(), "Group");
// Add the outline effect template to the effect stack template.
effectStackTemplate->addChild(outlineEffectTemplate);
// Add the shadow effect template to the effect stack template.
effectStackTemplate->addChild(shadowEffectTemplate);
// Create a prefab from the effect stack template.
NodeEffectPrefab2DSharedPtr effectStackPrefab =
NodeEffectPrefab2D::create(getDomain(), "Effect Stack prefab", effectStackTemplate);
// Assign the effect stack to a 2D node.
node->setEffectPrefab(effectStackPrefab);
// In the host node, set the shadow distance.
node->setProperty(ShadowEffect2D::DistanceProperty, 20.f);
See also
NodeEffectPrefab2D, NodeEffectTemplate2D
Since
Kanzi 3.9.0

Constructor & Destructor Documentation

◆ ~NodeEffect2D()

kanzi::NodeEffect2D::~NodeEffect2D ( )

◆ NodeEffect2D()

kanzi::NodeEffect2D::NodeEffect2D ( Domain * domain,
string_view name )
explicitprotected

Constructor.

Parameters
domainDomain to use.
nameResource name.

Member Function Documentation

◆ getEnabled()

bool kanzi::NodeEffect2D::getEnabled ( ) const
inline

Gets the value of EnabledProperty.

See also
setEnabled()
Since
Kanzi 3.9.8

◆ setEnabled()

void kanzi::NodeEffect2D::setEnabled ( bool value)
inline

Sets the value of EnabledProperty.

See also
getEnabled()
Since
Kanzi 3.9.8

◆ createRenderer()

NodeEffectRenderer2DUniquePtr kanzi::NodeEffect2D::createRenderer ( )

Creates a renderer instance.

Only single renderer instance may exist.

See also
NodeEffect2D::createRendererOverride.
Returns
NodeEffectRenderer2D instance.

◆ getEffectQuadPadding()

Vector4 kanzi::NodeEffect2D::getEffectQuadPadding ( ) const
inline

Gets the effect quad padding.

Returns
Effect quad padding as Vector4 where padding parameters are assigned as Vector4(left, right, top, bottom).

◆ getEffectQuadPaddingOffset()

Vector2 kanzi::NodeEffect2D::getEffectQuadPaddingOffset ( ) const
inline

Gets the effect quad offset relative relative to the top-left corner of the node.

Returns
Effect quad offset as Vector2.

◆ getEffectQuadPaddingSize()

Vector2 kanzi::NodeEffect2D::getEffectQuadPaddingSize ( ) const
inline

Gets the effect quad padding size.

Effect quad padding size defines how much the node quad size increases because of the effect padding.

Returns
Effect quad padding size as Vector2.

◆ getEffectPaddingChangeCounter()

unsigned int kanzi::NodeEffect2D::getEffectPaddingChangeCounter ( ) const
inline

Gets the effect quad padding change counter.

Kanzi updates the effect quad change count when the effect padding changes.

Returns
Effect padding change counter.

◆ setEffectPaddingChangeCounter()

void kanzi::NodeEffect2D::setEffectPaddingChangeCounter ( unsigned int value)
inline

Sets the effect quad padding change counter.

Parameters
valueEffect padding change counter value.
Since
Kanzi 3.9.8

◆ isAlphaRequired()

bool kanzi::NodeEffect2D::isAlphaRequired ( ) const
inline

Indicates whether the effect requires alpha channel for the result.

Returns
If alpha channel is required true, otherwise false.

◆ unregisterEffectRenderer()

void kanzi::NodeEffect2D::unregisterEffectRenderer ( NodeEffectRenderer2D * effectRenderer)
inline

Unregister effect renderer.

Effect renderer is automatically registered by NodeEffect2D::createRenderer() and unregistered by the NodeEffectRenderer2D destructor.

Parameters
effectRendererEffect renderer pointer to unregister.

◆ isRenderingRequired()

bool kanzi::NodeEffect2D::isRenderingRequired ( )
inline

Indicates whether the effect requires rendering.

Some effect property values can eliminate the need to render the effect. Typically this reflects a situation where the effect has no visible impact.

Returns
If effect rendering is required true, otherwise false.
Since
Kanzi 3.9.5

◆ getRendererInstance()

NodeEffectRenderer2D * kanzi::NodeEffect2D::getRendererInstance ( ) const
inline

Gets a pointer to NodeEffectRenderer2D instance or null pointer if none exists.

Returns
If the NodeEffectRenderer2D instance exists, a pointer to it, otherwise null pointer.

◆ createLookupContext()

BindingLookupContextPtr kanzi::NodeEffect2D::createLookupContext ( NodeEffect2DSharedPtr templateRoot)

Creates a lookup context for a given effect.

Parameters
templateRootTemplate root for given effect.
Returns
The effect lookup context.
Since
Kanzi 3.9.8

◆ getTemplateRoot()

NodeEffect2DSharedPtr kanzi::NodeEffect2D::getTemplateRoot ( ) const
inline

Gets the template root of this node effect.

Kanzi uses the template root internally in template root bindings.

Since
Kanzi 3.9.8

◆ setTemplateRoot()

void kanzi::NodeEffect2D::setTemplateRoot ( NodeEffect2DSharedPtr templateRoot)
inline

Sets the template root for this node effect.

Kanzi uses the template root internally in template root bindings.

Since
Kanzi 3.9.8

◆ isAttached()

bool kanzi::NodeEffect2D::isAttached ( ) const

Returns whether a node effect is attached to a node.

Returns
If the node effect is attached, true, otherwise false.
Since
Kanzi 3.9.8

◆ isAttaching()

bool kanzi::NodeEffect2D::isAttaching ( ) const

Returns whether a node effect is attaching to a node.

Returns
If the node effect is attaching, true, otherwise false.
Since
Kanzi 3.9.8

◆ isDetached()

bool kanzi::NodeEffect2D::isDetached ( ) const

Returns whether a node effect is detached from a node.

Returns
If the node effect is detached, true, otherwise false.
Since
Kanzi 3.9.8

◆ isDetaching()

bool kanzi::NodeEffect2D::isDetaching ( ) const

Returns whether a node effect is detaching from a node.

Returns
If the node effect is detaching, true, otherwise false.
Since
Kanzi 3.9.8

◆ getParent()

NodeEffect2D * kanzi::NodeEffect2D::getParent ( ) const
inline

Gets the parent of a node effect.

Returns
Pointer to parent node effect or, if the node effect does not have a parent, a nullptr.
Since
Kanzi 3.9.8

◆ setParent()

void kanzi::NodeEffect2D::setParent ( NodeEffect2D * parent)
inline

Sets the parent of a node effect.

Parameters
parentThe parent node effect.
Since
Kanzi 3.9.8

◆ lookupObject() [1/2]

ObjectSharedPtr kanzi::NodeEffect2D::lookupObject ( string_view relativePath)

Lookup for an object from the effect.

The object can be another effect, a node, or a resource within a node.

Parameters
relativePathRelative path to use for lookup.
Returns
Shared pointer that references the object or, if no object is found, null pointer.
Since
Kanzi 3.9.8

◆ lookupObject() [2/2]

template<typename T >
shared_ptr< T > kanzi::NodeEffect2D::lookupObject ( string_view relativePath)
inline

Lookup a relative object of a given type.

If the object is found but it is not of the given type, the search fails.

Returns
Shared pointer that references the object. If no object is found or the object is not of the correct type, returns a null pointer.
Since
Kanzi 3.9.8

◆ attach()

void kanzi::NodeEffect2D::attach ( Node * node)

Attaches the node effect.

Parameters
nodeOptional pointer to the node that hosts the effect.
Since
Kanzi 3.9.8

◆ detach()

void kanzi::NodeEffect2D::detach ( )

Detaches the node effect.

Since
Kanzi 3.9.8

◆ getHostNode()

Node * kanzi::NodeEffect2D::getHostNode ( ) const

Gets the node that hosts the effect.

Returns
The node that hosts the effect.
Since
Kanzi 3.9.8

◆ createRendererOverride()

virtual NodeEffectRenderer2DUniquePtr kanzi::NodeEffect2D::createRendererOverride ( )
protectedpure virtual

Creates a renderer instance.

Only single renderer instance may exist.

Returns
NodeEffectRenderer2D instance.

Implemented in kanzi::BlurEffect2D, kanzi::EffectStack2D, kanzi::MaskEffect2D, kanzi::OutlineEffect2D, and kanzi::ShadowEffect2D.

◆ initializeRendererOverride()

virtual void kanzi::NodeEffect2D::initializeRendererOverride ( )
protectedpure virtual

Initializes a previously created renderer instance.

Implemented in kanzi::BlurEffect2D, kanzi::EffectStack2D, kanzi::MaskEffect2D, kanzi::OutlineEffect2D, and kanzi::ShadowEffect2D.

◆ isRenderingRequiredOverride()

virtual bool kanzi::NodeEffect2D::isRenderingRequiredOverride ( )
protectedvirtual

Implementation-dependent check on whether effect rendering is required.

The default implementation always returns true. Individual effects must override this function to turn themselves off.

Returns
If effect rendering is required true, otherwise false.
Since
Kanzi 3.9.5

Reimplemented in kanzi::BlurEffect2D, kanzi::EffectStack2D, kanzi::OutlineEffect2D, and kanzi::ShadowEffect2D.

◆ setEffectQuadPadding()

void kanzi::NodeEffect2D::setEffectQuadPadding ( float left,
float right,
float top,
float bottom )
inlineprotected

Sets the padding required by the effect around the node bounds during the rendering of the effect.

Kanzi accounts for the effect quad padding when determining the visibility of the node.

◆ setAlphaRequired()

void kanzi::NodeEffect2D::setAlphaRequired ( bool required)
inlineprotected

Sets the framebuffer alpha channel requirements of the effect.

Parameters
requiredIf the effect rendering requires alpha channel and blending, true, otherwise false.

◆ onAttached()

virtual void kanzi::NodeEffect2D::onAttached ( )
protectedvirtual

Called by Kanzi when effect is attached.

Since
Kanzi 3.9.8

Reimplemented in kanzi::EffectStack2D.

◆ onDetached()

virtual void kanzi::NodeEffect2D::onDetached ( )
protectedvirtual

Called by Kanzi when effect is detached.

Since
Kanzi 3.9.8

Reimplemented in kanzi::EffectStack2D.

◆ lookupObjectOverride()

virtual ObjectSharedPtr kanzi::NodeEffect2D::lookupObjectOverride ( string_view initialPart,
string_view remainingPart )
protectedvirtual

Lookup for an object from the effect.

The object can be another effect, a node, or a resource within a node.

Parameters
initialPartThe leading part of the relative path before the first slash.
remainingPartThe trailing part of the relative part after the first slash.
Returns
Shared pointer that references the object or, if no object is found, null pointer.

Reimplemented in kanzi::EffectStack2D.

◆ onPropertyChanged()

void kanzi::NodeEffect2D::onPropertyChanged ( AbstractPropertyType propertyType,
PropertyNotificationReason reason )
overrideprotectedvirtual

Member Data Documentation

◆ EnabledProperty

PropertyType<bool> kanzi::NodeEffect2D::EnabledProperty
static

Sets whether the effect is enabled.

The default value is true.

See also
setEnabled(), getEnabled()
Since
Kanzi 3.9.8

The documentation for this class was generated from the following file: